package com.xoa.service.party;


import com.xoa.dao.party.MapOwnerinfoMapper;
import com.xoa.model.party.MapOwnerinfo;
import com.xoa.util.common.StringUtils;
import com.xoa.util.common.wrapper.BaseWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@Service
public class MapOwnerinfoService {
    @Autowired
    MapOwnerinfoMapper mapOwnerinfoMapper;

    public BaseWrapper queryCoordinatesByName(HttpServletRequest request, String name, String code){
        BaseWrapper baseWrapper=new BaseWrapper();
        List<MapOwnerinfo> mapOwnerinfos=mapOwnerinfoMapper.queryCoordinatesByName(name,code);
        baseWrapper.setStatus(true);
        if(mapOwnerinfos.size()>0){
            baseWrapper.setData(mapOwnerinfos);
            baseWrapper.setFlag(true);
        }else {
            baseWrapper.setFlag(false);
        }

        return  baseWrapper;
    }

    public BaseWrapper updateByIdSelective(HttpServletRequest request, MapOwnerinfo record){
        BaseWrapper baseWrapper=new BaseWrapper();
        baseWrapper.setStatus(true);
        if(StringUtils.checkNull(record.getMoiLabelname())){
            baseWrapper.setFlag(false);
            return  baseWrapper;
        }
        record.setMoiOwnername(record.getMoiLabelname());
        int total=mapOwnerinfoMapper.updateByIdSelective(record);
        if(total>0){
            baseWrapper.setData(record);
            baseWrapper.setFlag(true);
        }else{
            baseWrapper.setFlag(false);
        }

        return  baseWrapper;
    }

}
